﻿Imports MySoft.Map.Data
Imports System.Data.SqlClient
Imports System.Data
Imports Mysoft.CustomControl.AppGridEx


Partial Public Class WF_ProcessAnalysis_Grid
    Inherits Mysoft.Map.Application.Security.AppPage
  
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim mode As String = Request("mode")  '模式 0 为第一次加载 1 为点击查询后加载
        Dim buGUID As String = Request("BUGUID") '用户选择公司
        Dim beginDatetime As DateTime = CDate(Request("BeginDatetime")) '发起时间的起始日期
        Dim endDatetime As DateTime = CDate(Request("EndDatetime")) '发起时间的终止日期
        Dim sql As String

        If mode = "1" Then
            sql = GetAnalysisSql(buGUID, beginDatetime, endDatetime.AddDays(1))
        Else
            Return
        End If

        AppGridE1.Sql = sql


    End Sub

    Public Function GetAnalysisSql(ByVal buGUID As String, ByVal beginDatetime As DateTime, ByVal endDatetime As DateTime) As String
        Dim sql As System.Text.StringBuilder = New System.Text.StringBuilder()
        sql.Append(" EXEC usp_WF_ProcessAnalysis ")
        sql.AppendFormat(" @BUGUID = '{0}'", buGUID)
        sql.AppendFormat(",@BeginDatetime = '{0}'", beginDatetime.ToString("yyyy-MM-dd"))
        sql.AppendFormat(",@EndDatetime = '{0}' ", endDatetime.ToString("yyyy-MM-dd"))
        Return sql.ToString()
    End Function
End Class